﻿using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Cache.Memory
{
    public class MemoryCacheClient : IMemoryCacheClient
    {
        private IMemoryCache _memoryCache;
        public MemoryCacheClient()
        {
            _memoryCache = new MemoryCache(new MemoryCacheOptions());
        }

        public Task<long> AddListTail<T>(string key, T t)
        {
            throw new NotImplementedException();
        }

        public Task<long> AddListTail(string key, string value)
        {
            throw new NotImplementedException();
        }

        public Task<long> AddListTop<T>(string key, T t)
        {
            throw new NotImplementedException();
        }

        public Task<long> AddListTop(string key, string value)
        {
            throw new NotImplementedException();
        }

        public void AddSet(string key, string value)
        {
            throw new NotImplementedException();
        }

        public void BatchRemove(string[] keys)
        {
            throw new NotImplementedException();
        }

        public string[] GetMembers(string key)
        {
            throw new NotImplementedException();
        }

        public Task ListInsert<T>(string key, int index, T t)
        {
            throw new NotImplementedException();
        }

        public Task<long> ListLenght(string key)
        {
            throw new NotImplementedException();
        }

        public Task listPop(string key)
        {
            throw new NotImplementedException();
        }

        public Task<List<T>> ListRange<T>(string key, int startindex, int endIndex)
        {
            throw new NotImplementedException();
        }

        public void Remove(string key)
        {
            _memoryCache.Remove(key);
        }

        public bool SetRemove(string key, string value)
        {
            throw new NotImplementedException();
        }

        public T StringGet<T>(string key)
        {
            throw new NotImplementedException();
        }

        public string StringGet(string key)
        {
            string value = _memoryCache.Get(key) as string;
            return value;
        }

        public List<T> StringGetList<T>(string[] keys)
        {
            throw new NotImplementedException();
        }

        public void StringSet<T>(string key, T t, TimeSpan? expiry = null)
        {
            _memoryCache.Set(key, JsonConvert.SerializeObject(t));
        }
    }
}
